#ifndef SCREEN_RETURN_ZERO_TASK_H
#define SCREEN_RETURN_ZERO_TASK_H

#include "task/sync_task.h"

/**
 * @brief:  屏幕归位
 * @author: sherlock_lht
 */
class ScreenReturnZeroTask: public task::SyncTask
{
public:
    explicit ScreenReturnZeroTask(const std::string &name)
        : task::SyncTask(name)
    {
    }
    ~ScreenReturnZeroTask()
    {
        EASE_INFO("~ScreenReturnZeroTask");
    }

    bool onStart() override
    {
        EASE_INFO("name: %s, on start", task_name_.c_str());
        start_time_ = base::utils::DateTime::currentSecond();
        return true;
    }
    task::TaskStatus onRunning() override
    {
        int64_t now = base::utils::DateTime::currentSecond();
        if (now - start_time_ <= cost_time_)
        {
            return task::Running;
        }
        EASE_INFO("name: %s, on running", task_name_.c_str());
        EASE_INFO("name: %s, done", task_name_.c_str());
        return task::Success;
    }
    bool onPause() override
    {
        EASE_INFO("name: %s, on pause", task_name_.c_str());
        return true;
    }
    bool onResume() override
    {
        EASE_INFO("name: %s, on resume", task_name_.c_str());
        return true;
    }
    void onCancel() override
    {
        EASE_INFO("name: %s, on cancel", task_name_.c_str());
    }

private:
    int cost_time_{1};//s
    int64_t start_time_{};
};

#endif //SCREEN_RETURN_ZERO_TASK_H
